#ifndef SQUARE_H_
#define SQUARE_H_

#include <vector>
#include <iostream>
#include <functional>
#include <tr1/unordered_map>
/*
    struct for representing a square in the grid.
*/
struct Square
{
    short int ant, lastSeen,hillPlayer;
    short int tracking; //# of ants tracking this square either for food or enemy.
    bool isWater, isFood,isHill;
    std::vector<short int> deadAnts;

    Square()
    {
        isWater = isFood = 0;
        ant = -1;
        lastSeen = 0;
	tracking = 0;
	isHill = 0;
	hillPlayer=-1;
    };

    //resets the information for the square except water information
    void reset()
    {
	tracking = 0;
        isFood = 0;
	isHill=0;
        ant = hillPlayer =-1;
        deadAnts.clear();
    };

    Square& operator=(const Square& other) {
        this->isWater = other.isWater;
        this->isFood = other.isFood;
        this->isHill = other.isHill;
        this->ant = other.ant;
        this->lastSeen = other.lastSeen;
        this->hillPlayer = other.hillPlayer;
        this->deadAnts = other.deadAnts;
        this->tracking = other.tracking;
    }

    bool operator==(const Square& other) const {
	if (isWater!= other.isWater)
	    return false;
	if (isFood!=other.isFood)
	    return false;
	if (ant !=other.ant)
	    return false;
	if (lastSeen != other.lastSeen) 
	    return false;
	if (deadAnts !=other.deadAnts)
	    return false;
	if (isHill != other.isHill) 
	    return false;
	if (hillPlayer != other.hillPlayer) 
	    return false;
	return true;
    }
    friend std::ostream& operator<<(std::ostream& os,const Square& square);
};

std::ostream& operator<<(std::ostream& os,const Square& square);

namespace std {
    namespace tr1 {
        template<>
            struct hash<Square> {
            size_t operator()(const Square& x)  {
                return _Fnv_hash<>::hash((const char*)&x,sizeof(x));
            }
        };
    }
}

#endif //SQUARE_H_
